//
//  QJBaseView.m
//  QJWork
//
//  Created by qijia on 15/6/8.
//  Copyright (c) 2015年 高中雷. All rights reserved.
//

#import "QJBaseView.h"

@implementation QJBaseView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(void)LoadViewFromObject:(id)obj{
    self.curObject = obj;
}

-(void)controlAttributeProcessing{

}

-(void)goActionWithName:(NSString*)strName withSender:(id)sender
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(goActionWithName:withObject:withSender:)])
    {
        [self.delegate goActionWithName:strName withObject:self.curObject withSender:sender];
    }
}

-(void)goActionWithName:(NSString*)strName withObject:(id)obj withSender:(id)sender {
    if (self.delegate && [self.delegate respondsToSelector:@selector(goActionWithName:withObject:withSender:)])
    {
        [self.delegate goActionWithName:strName withObject:obj withSender:sender];
    }
}



-(void)reloadDatas {

    if (m_tableView) {
        [m_tableView reload:[self sortDatas] withRowAnimation:UITableViewRowAnimationNone];
    }
}

-(UITableView *)tableView{
    if(!_tableView){
        _tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.showsHorizontalScrollIndicator = NO;
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.backgroundColor = [UIColor whiteColor];
        _tableView.sectionIndexBackgroundColor = [UIColor clearColor];
        _tableView.sectionIndexColor = [UIColor clearColor];
    }
    return _tableView;
}

-(NSArray*)sortDatas {
    if (self.cellArray)
        return [NSArray arrayWithArray:self.cellArray];
    return @[];
}

-(NSMutableArray*)cellArray {
    if (!_cellArray) {
        _cellArray = [NSMutableArray array];
    }
    return _cellArray;
}




@end
